package com.quarantine.web.admin;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.quarantine.model.administrator;
import com.quarantine.service.AdministratorManager;
import com.quarantine.web.CrudActionSupport;


@Namespace("/admin")
 
@Results({
	@Result(name ="save", location = "administrator-admin!show.action", type ="redirect",params={"e","${e}"} ),
	 
})
public class AdministratorAdminAction extends CrudActionSupport<administrator> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1918666720864272801L;
    private AdministratorManager administratormanager;
    private administrator entity;
    private String password;
    private int e=0;
	@Override
	public administrator getModel() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String list() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
 
	@Override
	public String save() throws Exception {
		
		entity=administratormanager.findByLoginName("admin");
		System.out.println(password);
		System.out.println(entity.getId());
		System.out.println(entity.getPassword());
		System.out.println(entity.getLoginName());
		entity.setPassword(password);
		administratormanager.save(entity);
	    e=1;
		return "save";
	}
    public String show() {
		
    	entity=administratormanager.findByLoginName("admin"); 
		
		return "show";
	}

	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void prepareModel() throws Exception {
		// TODO Auto-generated method stub
		
	}

	public AdministratorManager getAdministratormanager() {
		return administratormanager;
	}
	@Autowired
	public void setAdministratormanager(AdministratorManager administratormanager) {
		this.administratormanager = administratormanager;
	}

	public administrator getEntity() {
		return entity;
	}

	public void setEntity(administrator entity) {
		this.entity = entity;
	}
 

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getE() {
		return e;
	}

	public void setE(int e) {
		this.e = e;
	}

}
